<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="Specials.Specials" %>
<%@ page import="Page.Page"   %>
<%@ page import="java.util.*"  %>
<%@ page import="Specials.SpecialsDeal"%>
<%
   //从数据库中去出结果集
   int currentRecord = 0;
   String ComID="";
   Page pager=new Page();
   SpecialsDeal db=new SpecialsDeal();
   //此处需要改
   String SellerID="1";
   ArrayList<Specials> result =db.ShowSpecials(); 
   pager.setPageSize(10);
   pager.setTotalRecord(result.size());
   pager.setTotalPage(result.size(),pager.getPageSize());
   //计算并设置分页的参数
   if(request.getParameter("currentRecord")!=null)
   {   
       currentRecord = Integer.parseInt(request.getParameter("currentRecord"));
       pager.setCurrentRecord(currentRecord);
       pager.setCurrentPage(currentRecord,pager.getPageSize());
   }
   //从结果集中取出当前页面要显示的子集
   List<Specials> subResult = null;
   if(currentRecord == 0)
   {
       if(currentRecord+pager.getPageSize()<=result.size())
       {
            subResult = result.subList(0,pager.getPageSize());
       	
       }
       else
       {
       	   	subResult = result.subList(0,result.size());
       }
   
   }
   else if(pager.getCurrentRecord()+pager.getPageSize()<result.size())
       subResult = result.subList(pager.getCurrentRecord(),pager.getCurrentRecord

()+pager.getPageSize());
   else
       subResult = result.subList(pager.getCurrentRecord(),result.size());
 %>
<html>
  <head>
  </head>

  <body>
  <font size="2"><strong>申请信息如下：</strong><br>
   </font>
   <form name="From1" method="POST" action="GridCommodityShow.jsp">
	  	<table width="1000" border="20" height="600" align=center>
   		<%
   			 if(subResult.isEmpty()==false)
		       {
		             for(int i=0;i<subResult.size();i++)
		             {
		            	 Specials Specials = subResult.get(i);
		            	 SpecialsDeal d=new SpecialsDeal();
		            	 String ComImage=d.CalComImage(Specials.getComID());
		            	 out.print("<script>alert('"+ComImage+"')</script>");
		                 String saveurl=request.getRealPath("/")+ComImage;
		            	 if(i%5==0)
		            	 {
		            		 out.print("<tr  height=289 align=left valign=top>");
		            	 }
		                 out.print("<td width=180 border=1>");
		            	 out.print("<table width=160 border=1>");
		            	 out.print("<tr align=left valign=top >");
		            	 out.print("<td width=160>");
		            	 out.print("<a href='../GridCommodity/GridCommodityDetailed.jsp?jp="+"../Specials/SpecialsShow.jsp"+"&GridComID="+Specials.getComID()+"'>");
		            	 out.print("<img border=0 width=150 height=200 src=");
		            	 out.print("../"+ComImage);
		            	 out.print("></a>");
		                 out.print("</td>");
		                 out.print("<tr>");
		                
		                 out.print("<td align=center>");
		                
		                 out.print("<a href='../GridCommodity/GridCommodityDetailed.jsp?jp="+"../Specials/SpecialsShow.jsp"+"&GridComID="+Specials.getComID()+"'>");
		                 out.print(Specials.getComName());
		                 out.print("</a>");
		                 out.print("</td>");
		                 out.print("</tr>");
		                 
		                 out.print("<tr>");
		                 out.print("<td align=center>");
		                 out.print("￥"+Specials.getComPrice());
		                 out.print("</td>");
		                 out.print("</tr>");
		                 out.print("<tr>");
		                 out.print("<td align=center>");
		                 out.print(""+Specials.getDisCount()+"折");
		                 out.print("</td>");
		                 out.print("</tr>");
		                 out.print("</table>");
		                 out.print("</td>");
		                 
		                
		                
		                 if(i%5==4)
		                 {
		                	 out.print("</tr>");
		                 }
		           
		             }
		        }
   		 %>	
   	</table>
   	<span><font size="2">总<%=pager.getTotalRecord()%>条记录|总<%=pager.getTotalPage()%>页|当

前<%=pager.getCurrentPage()+1%>页|每页<%=pager.getPageSize()%>条|
<% 
    //如果已经到了首页就去掉前一页的链接
    if(pager.getCurrentRecord()-pager.getPageSize()<0)
        out.println("首页|");
    else
    //上一页就是把当前记录位置减去一页显示记录的条数
        out.print("<a href='SpecialsShow.jsp?currentRecord="+(pager.getCurrentRecord()-

pager.getPageSize())+"&pageSize="+pager.getPageSize()+"'>上一页</a>|");
    //如果到了尾页就去掉下一页的链接
    if(pager.getCurrentRecord()+pager.getPageSize()>=pager.getTotalRecord())
        out.println("尾页");
    else
    //下一页就是把当前记录位置加上一页显示记录的条数
        out.print("<a href='SpecialsShow.jsp?currentRecord="+(pager.getCurrentRecord

()+pager.getPageSize())+"&pageSize="+pager.getPageSize()+"'>下一页</a>|"); 
%>
</font></span>
</form>
  </body>
</html>
